package com.course.serviceImpl;

import com.course.daoI.UserDAoI;
import com.course.daoImpl.UserDaoImpl;
import com.course.exception.ConnectionException;
import com.course.exception.DataNotFoundException;
import com.course.exception.LoginException;
import com.course.serviceI.UserServiceI;
import com.course.util.CoreList;

public class UserServiceImpl implements UserServiceI{
	
	UserDAoI udao=new UserDaoImpl();
	
	boolean flag=false;

	public boolean deleteFaculty(int cid, String login)
			throws LoginException, ConnectionException {
		flag=udao.deleteFaculty(cid, login);
		    if(flag==false)
			{
				throw new ConnectionException();
				}
	       else if(cid==0||login==null) {
				throw new LoginException();
				}
			return flag;
		}

	public boolean deleteStudent(int cid, int uid)
			throws LoginException, ConnectionException {
		
		flag=udao.deleteStudent(cid, uid);
		
		 if(flag==false)
			{
				throw new ConnectionException();
				}
	       else if(cid==0||uid==0) {
				throw new LoginException();
				}
			return flag;
		}

	public CoreList getEmpDetails(String path) throws DataNotFoundException,
			ConnectionException {
		
		CoreList cl=udao.getEmpDetails(path);
		
        if (cl.isEmpty()) {
			
			throw new DataNotFoundException();
			
		   }
		      return cl;
		      }

	public CoreList getFaculty(String path, int courid)
			throws DataNotFoundException, ConnectionException {
		
		
		CoreList cl=udao.getFaculty(path, courid);
		
		
		 if (cl.isEmpty()) {
				throw new DataNotFoundException();
				
			   }
			      return cl;
		}

	public CoreList getStudents(String path) throws DataNotFoundException,
			ConnectionException {
		
		
		CoreList cl=udao.getStudents(path);
		
		if (cl.isEmpty()) {
			throw new DataNotFoundException();
			
		   }
		      return cl;
		}

	public CoreList getStudentsInfo(String path, int courid)
			throws DataNotFoundException, ConnectionException {
		
		
		CoreList cl=udao.getStudentsInfo(path,courid);
		
		if (cl.isEmpty()) {                                                                                                                                                                                                                                                        
			throw new DataNotFoundException();
			
		   }
		      return cl;
		
		
		
	}
	
	
	

}
